//
//  KnowledgeDetailVC.m
//  ProjectA
//
//  Created by lioccord on 15-3-7.
//  Copyright (c) 2015年 李赐岩 姜雪 张昕锐. All rights reserved.
//

#import "KnowledgeDetailVC.h"

@interface KnowledgeDetailVC ()

@end

@implementation KnowledgeDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];
    // Do any additional setup after loading the view.
    
    
    NSLog(@"detail ID %ld", self.identify);
    

    //创建 webview
    UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 50)];
    
    webview.delegate = self;
    webview.scalesPageToFit = YES;
    
    [self.view addSubview:webview];
    
    //创建 request
    NSString *url_string = [NSString stringWithFormat:@"http://ibaby.ipadown.com/api/food/food.tips.detail.php?id=%ld", self.identify];
    
    NSURL *url=[NSURL URLWithString:url_string];//创建URL
    
    NSMutableURLRequest *request=[[NSMutableURLRequest alloc]initWithURL:url];//通过URL创建网络请求
    
    [webview loadRequest:request];  //通过 request 请求
    
    
    //加载动画
    self.indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0,162,162)];
    self.indicator.center = self.view.center;
    [self.indicator setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyleGray)];
    [self.view addSubview:self.indicator];
    
    //分享按钮
//    self.isOn = NO;
//    UIImage *image = [UIImage imageNamed:@"star_faved@2x.png"];
//    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    
//    
//    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(shareButtonAct:)];
    

   
} //did load

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)webViewDidStartLoad:(UIWebView *)webView{
    
    [self.indicator startAnimating];
    
}//webview 开始加载


-(void)webViewDidFinishLoad:(UIWebView *)webView{
    
    [self.indicator stopAnimating];
    
}//webview 加载结束


//-(void)shareButtonAct:(UIBarButtonItem *)sender{
//    NSLog(@"share   ");
//    
//    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle: @"返回" destructiveButtonTitle:nil otherButtonTitles:@"分享",@"收藏" , nil];
//    
//    [sheet showInView:self.view];
//    
//}//分享按钮
//
//
//-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
//    
//    if (0 == buttonIndex) {
//        NSLog(@"share");
//        
//        //微博分享
//        [UMSocialSnsService presentSnsIconSheetView:self appKey:@"507fcab25270157b37000010" shareText:@"我看到了一个很不错的小知识~(来自 上得厅堂)" shareImage:nil shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina, nil] delegate:self];
//        
//        
//        
//    }else if (1 == buttonIndex){
//        NSLog(@"collect");
//        
//    }
//    
//}// action sheet 点击动作
//

@end












